package com.xuecheng.manage_cms.dao;

/**
 * @Author: Gosin
 * @Date: 2020/5/18 23:07
 */
public class ThreadTest_1 {
    static volatile long[] arr = new long[16];
    public static void main(String[] args) throws InterruptedException{
        Thread thread1 = new Thread(() -> {
            for(long i = 0;i<10000_0000L;i++){
                arr[0] = i;
            }
        });

        Thread thread2 = new Thread(() -> {
            for(long i = 0;i<10000_0000L;i++){
                arr[8] = i;
            }
        });

        final long start = System.nanoTime();
        thread1.start();
        thread2.start();
        thread1.join();
        thread2.join();
        System.out.println(System.nanoTime()-start);
    }
}
